package com.xbenben.project.common.model;

public class DefaultFacadeResponse<T> extends AbstractFacadeResp {

    public static final String DEFAULT_ERROR_MSG = "系统繁忙";
    private T data;

    public DefaultFacadeResponse() {
    }

    public DefaultFacadeResponse(boolean success) {
        super(success);
    }

    public DefaultFacadeResponse(boolean success, T data) {
        this(success, data, null, null);
    }

    public DefaultFacadeResponse(boolean success, T data, String message) {
        this(success, data, message, null);
    }

    public DefaultFacadeResponse(boolean success, T data, Exception e) {
        this(success, data, null, e);
    }

    public DefaultFacadeResponse(boolean success, T data, String message, Exception e) {
        this(success);
        this.setData(data);
        this.setException(e);
        this.setResultMsg(message);
    }

    public DefaultFacadeResponse(boolean success, String errorCode, String message) {
        this(success);
        this.setResultMsg(message);
        this.setErrorCode(errorCode);
    }

    public DefaultFacadeResponse(String errorCode, String message) {
        this(false, errorCode, message);
    }

    public static DefaultFacadeResponse getErrorDefaultResponse() {
        DefaultFacadeResponse response = new DefaultFacadeResponse(false);
        response.setResultMsg(DEFAULT_ERROR_MSG);
        response.setErrorCode("E999999");
        return response;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
